import ajax from '@/http/ajax'
import router from '@/router/index'
import {useToDoList} from "@/store/toDoList";

export default function () {

    const toDoList = useToDoList()

    function addToDo(title: string, content: string) {
        ajax({
            url: '/posts',
            method: 'POST',
            data: {
                title,
                status: false,
                content
            }
        }).then(r => {
            console.log(r.data)
            alert('添加成功')
            toDoList.getData()
            router.push('/toDoPage').then()
        })
    }
    return {addToDo}
}